home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / U-Z / VideoToolBox Folder / VideoToolboxSources / TrapAvailable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-23  |  863 b   |  45 lines  |  [TEXT/KAHL]

  1. /*
  2. TrapAvailable.c
  3. From Apple. Simply include <Traps.h> in your program and call this routine to find
  4. out whether any particular trap is available.
  5. */
  6. #include "VideoToolbox.h"
  7. #include <Traps.h>
  8.  
  9. // these are for internal use only
  10. short NumToolboxTraps(void);        
  11. TrapType GetTrapType(short theTrap);
  12.     
  13. Boolean    TrapAvailable(short theTrap)
  14. {
  15.     TrapType tType;
  16.     
  17.     tType = GetTrapType(theTrap);
  18.     if (tType == ToolTrap) {
  19.         theTrap &= 0x07FF;
  20.         if (theTrap >= NumToolboxTraps())
  21.             theTrap = _Unimplemented;
  22.     }
  23.     
  24.     return NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  25. }
  26.  
  27. short NumToolboxTraps(void)
  28. {
  29.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  30.         return 0x0200;
  31.     else
  32.         return 0x0400;
  33. }
  34.  
  35.  
  36. TrapType GetTrapType(short theTrap)
  37. {
  38.     if ((theTrap & 0x0800) > 0)
  39.         return ToolTrap;
  40.     else
  41.         return OSTrap;
  42. }
  43.  
  44.  
  45.